package com.qire.manhua.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;
import com.qire.common.constant.Navigation;
import com.qire.common.inject.EventControllerInjector;
import com.qire.common.support.base.BaseFragment;
import com.qire.manhua.R;
import com.qire.manhua.controller.RecommendUpdateController;
import com.qire.manhua.databinding.FragmentRecommendUpdateBinding;
import com.qire.manhua.model.viewModel.impl.RecommendUpdateViewModel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * 首页(Home) -> 推荐页 -> 更新
 */
@RouteMapping(path = Navigation.Fragment.RecommendUpdateFragment)
public class RecommendUpdateFragment extends BaseFragment<FragmentRecommendUpdateBinding> {

    @Autowired
    RecommendUpdateViewModel viewModel;

    @Autowired(injector = EventControllerInjector.class)
    RecommendUpdateController controller;

    @Override
    public int layoutRid() {
        return R.layout.fragment_recommend_update;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View rootView = super.onCreateView(inflater, container, savedInstanceState);

        FragmentRecommendUpdateBinding viewDataBinder = viewDataBinder();

        viewDataBinder.setRecommendUpdateViewModel(viewModel);

        viewModel.onAddition(controller);
        controller.onAddition(viewModel);

        viewModel.loadUpdateComicData();

        return rootView;
    }

}
